""" Dashboard views """

from django.shortcuts import render_to_response
from django.contrib.auth.decorators import login_required, user_passes_test


# HELPERS
def is_active_test(user):
    """
    Checks if user is not and AnonymousUser (ie. has provided valid credentials)
    and is still an active user, then returns that result.
    """
    return (user.is_authenticated and user.is_active)


# VIEWS
###############################################################################
@login_required
@user_passes_test(is_active_test)
def home(request):
    return render_to_response('dashboard/home.html', {'user': request.user})
